<!-- 
  Authors: M.Ravi (st111222)
           Orathai Dumrongsukniwat (st111002)
  Date: 17 September, 2010
-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<title>Quotations</title>
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
<center>
<div>
<% form_tag({:controller => "basics", :action => 'quotationSearchResults'}, :method => "post") do %>
	<%= label_tag(:q, "Keywords: ") %>
	<%= text_field_tag :q, nil, :size => 50 %>
	<%= submit_tag("Search") %>
<% end %>

</div>
<br/>
<div>
<% form_tag({:controller => "basics", :action => 'import_xml'}, :method => "get") do %>
	<%= label_tag(:selWeb, "Another Web Server : ") %>
      	<%= select_tag(:selWeb, options_for_select({ 
			"Please Select" => "None",
			"Web 01" => "http://web1.cs.ait.ac.th/basics/quotations_xml", 
			"Web 02" => "http://web2.cs.ait.ac.th/basics/quotations_xml",
			"Web 03" => "http://web3.cs.ait.ac.th/basics/quotations_xml", 
			"Web 04" => "http://web4.cs.ait.ac.th/basics/quotations_xml",
			"Web 05" => "http://web5.cs.ait.ac.th/basics/quotations_xml", 
			"Web 06" => "http://web6.cs.ait.ac.th/basics/quotations_xml",
			"Web 07" => "http://web7.cs.ait.ac.th/basics/quotations_xml", 
			"Web 08" => "http://web8.cs.ait.ac.th/basics/quotations-xml", 
			"Web 09" => "http://web9.cs.ait.ac.th/basics/quotations_xml", 
			"Web 10" => "http://web10.cs.ait.ac.th/basics/quotations_xml"
			}.sort, "None")) 
	%>
	<%= submit_tag("Import XML") %>
<% end %>
</div>

<div style="padding: 38px 0pt 3px;">
<h3>Quotations</h3>
<% if cookies[:exclude] %>
<%= link_to "Erase My Personalization", :action=> "eraseMyPersonalization" %>&nbsp;&nbsp;&nbsp;
<% end %>
<% if params[:sort_by] == "date" %>
	<%= link_to "Sort by category", :action => :quotations, :sort_by => :category %>
<% else %>
	<%= link_to "Sort by date", :action => :quotations, :sort_by => :date %>
<% end %>
&nbsp;&nbsp;&nbsp;
<%= link_to "Generates XML", :action=> "quotations-xml" %>
&nbsp;&nbsp;&nbsp;
<%= link_to "DB Exercises", :action=> "showDBExercises" %>
<div align="left">
<ul>
	<% for quotation in @quotations 
		%>
		<li><%= h quotation.author_name %>: <%= h quotation.quote %>&nbsp;&nbsp;&nbsp;<%= h link_to "kill", :action => "killCookie" ,:author_name => quotation.author_name, :quote => quotation.quote, :sort_by => @oby %>
  </li>

	<% end %>
</ul>
</div>
<br/>
<hr/>
<h3>New quotation</h3>
<% form_for @quotation, :url => { :action => :quotations } do |form| %>
<div align="left" style="padding-left:100px;">
<%= notice %>
<%= form.error_messages %>
</div>
	<fieldset>
		<legend>Enter details</legend>
		<div class="form_row">
			<%= form.label :author_name %>
			<%= form.text_field :author_name, :size => 20, :maxlength => 40 %>
		</div>

                <div class="form_row">
                        <%= radio_button_tag :optCat, "old", true %>
                           <%= form.label :category %>
                           <%=
	                      select_tag :selCat, options_from_collection_for_select(@categories, "category", "category")
                           %>
                           <br/>
                        <%= radio_button_tag :optCat, "new", false %>
                           <%= form.label "New_Category" %>
                           <%= form.text_field :category, :size => 20, :maxlength => 40 %>
                </div>

		<div class="form_row">
			<%= form.label :quote %>
			<%= form.text_area :quote, :rows => 2, :cols => 40 %>
		</div>
	</fieldset>
			<div class="form_row">
				<%= form.submit 'Create' %>
			</div>
	<% end %>
</div>
<!-- FOOTER -->
<%= render :file => 'layouts/footer',:program_name => @program_name %>
<!-- FOOTER END -->
</center>
</body>
</html>
